package com.ynny.usermanager.service;

import com.ynny.usermanager.dao.UserDao;
import com.ynny.usermanager.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserDao userDao;

    @Override
    public int saveUser(User user) {
        //判断用户名是否存在
       User repeatUser =
               userDao.selectUserByUserName(user.getUsername());

       if (repeatUser != null){
           return 202;
       }

       int i = userDao.addUser(user);
       if (i > 0){
           return 200;
       }

       return 503;

    }
}
